package xyz.xpman.prisonerfitness.util;


import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

/**
 * @author 江理_网猿 (timor)
 * @date 2019/11/18 0018
 */
@SuppressWarnings("unused")
public class MyUuidUtil {

    public static String get(){
        String uuid = UUID.randomUUID().toString();

        StringBuilder sb = new StringBuilder(uuid);
        sb.deleteCharAt(23).deleteCharAt(18);
        sb.deleteCharAt(13).deleteCharAt(8);
        return sb.toString();
    }

    public static String get2(){
        return UUID.randomUUID().toString()
                .replaceAll("-", "");
    }

    public static String getUUID(){
        return get();
    }

    public static String by(String name){
        return UUID.fromString(name).toString();
    }

    public static String by(byte[] name){
        return UUID.nameUUIDFromBytes(name).toString();
    }



    public static String[] getArray(int num) {
        if(num >= 1){
            String[] uuid = new String[num];
            for (int i = 0; i < num; i++) {
                uuid[i] = get();
            }
            return uuid;
        }
        return null;
    }

    public static List<String> getList(int num) {
        return Arrays.asList(Objects.requireNonNull(getArray(num)));
    }
}
